﻿<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>QQ消息管理器</title>
<style type="text/css">
/* scroll */
::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-button{ width:0; height:0; }
::-webkit-scrollbar-button:start:decrement,::-webkit-scrollbar-button:end:increment{ display:block; }
::-webkit-scrollbar-button:vertical:start:increment,::-webkit-scrollbar-button:vertical:end:decrement { display:none; }
::-webkit-scrollbar-corner{ display:block; }

::-webkit-scrollbar-thumb{
	background-clip:padding-box;
	background-color:rgba(0,0,0,.2);
	border-radius:8px;
}
::-webkit-scrollbar-thumb:hover{
	background-clip:padding-box;
	background-color:rgba(0,0,0,.5);
	border-radius:8px;
}
::-webkit-scrollbar-track:vertical,::-webkit-scrollbar-thumb:vertical{
	border-left:1px solid transparent;
	border-right:1px solid transparent;
}
::-webkit-scrollbar-track:horizontal,::-webkit-scrollbar-thumb:horizontal{
	border-top:1px solid transparent;
	border-bottom:1px solid transparent;
}
::-webkit-scrollbar-track:hover{
	background-clip:padding-box;
	background-color:rgba(0,0,0,.15);
}

::-webkit-scrollbar-button:vertical:start{width:10px;height:10px;background:url(qq:///txfile/systheme:ScrollBar/scrollbar_arrow.png) no-repeat 0 0}
::-webkit-scrollbar-button:vertical:start:hover{background:url(qq:///txfile/systheme:ScrollBar/scrollbar_arrow.png) no-repeat -15px 0}
::-webkit-scrollbar-button:vertical:start:active{background:url(qq:///txfile/systheme:ScrollBar/scrollbar_arrow.png) no-repeat -30px 0}
::-webkit-scrollbar-button:vertical:end{width:10px;height:10px;background:url(qq:///txfile/systheme:ScrollBar/scrollbar_arrow.png) no-repeat 0 -18px}
::-webkit-scrollbar-button:vertical:end:hover{background:url(qq:///txfile/systheme:ScrollBar/scrollbar_arrow.png) no-repeat -15px -18px}
::-webkit-scrollbar-button:vertical:end:active{background:url(qq:///txfile/systheme:ScrollBar/scrollbar_arrow.png) no-repeat -30px -18px}
/ scroll */
</style>
<script language="javascript">

var g_rowObjLastSave;
var g_rowObjLastSelByKeyDown;
// var g_dwIEVersion = 5;
var g_nRowObjCount = 0;
var g_clrBgSel ;
var g_clrBorder1;
var g_clrBorder2;
var g_clrBorderSel;
var g_listMsgIndex = "";
var g_notify = true;
var g_gotoBottom = false;

function OnThemeColorChange()
{
    g_clrBgSel = external.GetColor("#ffedc4");
    g_clrBorder1 = external.GetColor("#FAFBFB");
    g_clrBorder2 = external.GetColor("#F5F8FA");
    g_clrBorderSel = external.GetColor("#ffdb8d");    

    try
    {
        /*with(document.body.style)
        { 
            scrollbar3dLightColor = external.GetColor("#BAC7DB") ;
            scrollbarArrowColor = external.GetColor("#81B0D4"); 
            scrollbarDarkShadowColor = external.GetColor("#FFFFFF") ;
            scrollbarFaceColor = external.GetColor("#F5F8FC") ;
            scrollbarHighlightColor = external.GetColor("#FFFFFF" );
            scrollbarShadowColor = external.GetColor("#BAC7DB") ;
            scrollbarTrackColor = external.GetColor("#F4F7FA" );
        } */

		if (ItemTable.rows.length > 0)
		{
			for(i = 0; i < ItemTable.rows.length; i++)
			{
				if (g_rowObjLastSave == ItemTable.rows[i])
				{
					ItemTable.rows[i].style.backgroundColor = g_clrBgSel;
					if (ItemTable.rows[i].cells.length > 0)
					{
						ItemTable.rows[i].cells[0].style.cssText = "border:1px " + g_clrBorderSel + " solid;";
					}
				}
				else
				{
					var bkIndex = ItemTable.rows[i].getAttribute("bkIndex");
					var bdclr = g_clrBorder1;
					if (bkIndex == 2) 
					{
						bdclr = g_clrBorder2;
					}
					ItemTable.rows[i].style.backgroundColor = bdclr;
					ItemTable.rows[i].style.borderColor = bdclr;
					if (ItemTable.rows[i].cells.length > 0)
					{
						ItemTable.rows[i].cells[0].style.cssText = "border:1px " + bdclr + " solid;";
					}
				}
			}
		}	
/*		if (g_dwIEVersion > 5)
        {
    	    if (ItemTable.rows.length > 0)
   	        {
   		        for(i = 0; i < ItemTable.rows.length; i++)
    		    {
			        if (g_rowObjLastSave == ItemTable.rows[i])
            		{
                	    ItemTable.rows[i].style.backgroundColor = g_clrBgSel;
				        if (ItemTable.rows[i].cells.length > 0)
				        {
				            ItemTable.rows[i].cells[0].style.cssText = "border:1px " + g_clrBorderSel + " solid;";
				        }
             		}
			        else
          	        {
          		        var bkIndex = ItemTable.rows[i].getAttribute("bkIndex");
          		        var bdclr = g_clrBorder1;
                        if (bkIndex == 2) 
                        {
	                        bdclr = g_clrBorder2;
    	                }
	   			        ItemTable.rows[i].style.backgroundColor = bdclr;
	   			        ItemTable.rows[i].style.borderColor = bdclr;
				        if (ItemTable.rows[i].cells.length > 0)
				        {
				            ItemTable.rows[i].cells[0].style.cssText = "border:1px " + bdclr + " solid;";
				        }
                    }
		        }
	        }
        }*/
    }
    catch(e){}
}

function GetMsgIndex(rowObj)
{
   if(rowObj != null)
     return rowObj.rowIndex - rowObj.getAttribute("dCount");
   
   return 0;
}

function OnClickImage(bsError, dwMsgIndex, dwElemIndex, dwRowId, image)
{
    var rowObj = document.getElementById("itemId_"+dwRowId);
    if(rowObj != null)
	{
		if (image)
		{
			var left = image.getBoundingClientRect().left;
			var top = image.getBoundingClientRect().top;
			var right = image.getBoundingClientRect().right;
			var bottom = image.getBoundingClientRect().bottom;

			external.ClickImage(bsError, dwMsgIndex, dwElemIndex, GetMsgIndex(rowObj), left, top, right, bottom);
			return;
		}
		
		external.ClickImage(bsError, dwMsgIndex, dwElemIndex, GetMsgIndex(rowObj)); 
	}	
}

function OnRClickImage(bsError, dwMsgIndex, dwElemIndex, dwRowId)
{
    var rowObj = document.getElementById("itemId_"+dwRowId);
    if(rowObj != null)
        external.RClickImage(bsError, dwMsgIndex, dwElemIndex, GetMsgIndex(rowObj));      
}

function OnClickReply(bsType, bsKey, datetime)
{
	external.OnClickReply(bsType, bsKey);
}

function OnDisposeItem(rowObj, datetime)
{
    var index = GetMsgIndex(rowObj)
    external.OnDisposeItem(index);
}

function OnDbClickItem(rowObj)
{
   var index = GetMsgIndex(rowObj)
   external.ClickItem(index);
}

function OnMouseDownItem(rowObj)
{
   if (2 != event.button)
   {
      return;
   }
   g_rowObjLastSelByKeyDown = rowObj;
    var bMultiSel = false;
    if (external.EnableMultiSel() && (g_rowObjLastSave !=null) && ( external.GetKeyState(17) < 0 || external.GetKeyState(16)<0))
    {
         bMultiSel = true;
         
         if (external.GetKeyState(16)<0) ///shift
         {
	        ResetMultiSel();
            var row1 = GetMsgIndex(rowObj);
            var row2 = GetMsgIndex(g_rowObjLastSave);
            if (row1 < row2)
	        {
	            for(i=row1;i<=row2;i++)
	            {
	                var item = document.getElementById("itemId_"+i);
                    AddToMultiSel(item,false);
	            }
	        }
            else
            {
                for(i=row2;i<=row1;i++)
                {
                    var item = document.getElementById("itemId_"+i);
                    AddToMultiSel(item,false);
                }
            }
        }
        else
        {
            AddToMultiSel(rowObj,false);  //ctrl
        }
    }
    else
    {
        ResetMultiSel();
        ResetStyle(g_rowObjLastSave);
        SetSelStyle(rowObj);
    }   
    if (!bMultiSel )
    {
       g_rowObjLastSave = rowObj;
       if (g_notify)
       {
            external.SetCurSel(GetMsgIndex(g_rowObjLastSave));
       }       
    }
	else
	{
	    if (g_notify)
        {
            external.SetMultiCurSel(GetMsgIndex(rowObj));
        }  
	}
}
/*
function OnMouseTrackIn(rowObj)
{
    if (rowObj.all.tn.all.tv != null)
    {
        rowObj.all.tn.all.tv.style.visibility='visible';
    }
    if (rowObj.all.tn.all.tv_reply != null)
    {
        rowObj.all.tn.all.tv_reply.style.visibility='visible';
    }
}

function OnMouseTrackOut(rowObj)
{
    if (rowObj.all.tn.all.tv != null)
    {
        rowObj.all.tn.all.tv.style.visibility='hidden';
    }
    if (rowObj.all.tn.all.tv_reply != null)
    {
        rowObj.all.tn.all.tv_reply.style.visibility='hidden';
    }
}*/
function OnMouseTrackIn(rowObj)
{
	var childs = rowObj.childNodes;
	for (var i = 0; i < childs.length; i++)
	{
		if (childs[i].getAttribute("id") == 'tn')
		{
			var grandchilds = childs[i].childNodes;
			for (var j = 0; j < grandchilds.length; j++)
			{
				var reply = grandchilds[j];
				if (reply == null)
				{
					continue;
				}

				if (reply.getAttribute("id") == 'tv_reply')
				{
					reply.style.visibility='visible';
				}
				else if (reply.getAttribute("id") == 'tv')
				{
					reply.style.visibility='visible';
				}		
			}
			if (childs[i].firstChild != null)
			{
				var reply = childs[i].firstChild.firstChild;
				if (reply == null)
				{
					continue;
				}

				if (reply.getAttribute("id") == 'tv_reply')
				{
					reply.style.visibility='visible';
				}
				else if (reply.getAttribute("id") == 'tv')
				{
					reply.style.visibility='visible';
				}
			}
		}
	}
}

function OnMouseTrackOut(rowObj)
{
	var childs = rowObj.childNodes;
	for (var i = 0; i < childs.length; i++)
	{
		if (childs[i].getAttribute("id") == 'tn')
		{
			var grandchilds = childs[i].childNodes;
			for (var j = 0; j < grandchilds.length; j++)
			{
				var reply = grandchilds[j];
				if (reply == null)
				{
					continue;
				}

				if (reply.getAttribute("id") == 'tv_reply')
				{
					reply.style.visibility='hidden';
				}
				else if (reply.getAttribute("id") == 'tv')
				{
					reply.style.visibility='hidden';
				}		
			}
			if (childs[i].firstChild != null)
			{
				var reply = childs[i].firstChild.firstChild;
				if (reply == null)
				{
					continue;
				}

				if (reply.getAttribute("id") == 'tv_reply')
				{
					reply.style.visibility='hidden';
				}
				else if (reply.getAttribute("id") == 'tv')
				{
					reply.style.visibility='hidden';
				}
			}
		}
	}
}

function AddToMultiSel(rowObj, bCheck)
{   
    if (!bCheck)
    {
        SetSelStyle(rowObj);
        g_listMsgIndex += GetMsgIndex(rowObj);
        g_listMsgIndex += ",";
    }
    else
    {
        var id = GetMsgIndex(rowObj);
        if (g_listMsgIndex!="")
        {
            var bfind = false;
            var d = new Array();   
            d = g_listMsgIndex.split(",");   
            g_listMsgIndex="";
            for (var i = 0; i < d.length; i++)   
            {   
                var m = d[i];
                if (m!="")
                {
                    if ( m==id )
                    {
                        bfind = true;
                    }
                    else
                    {
                        g_listMsgIndex += m;
                        g_listMsgIndex += ",";
                    }
                 }
             }
           
             if (!bfind)
             {
                g_listMsgIndex += id;
                g_listMsgIndex += ",";
                SetSelStyle(rowObj);
             }
             else
             {
                var item = document.getElementById("itemId_"+id);
                ResetStyle(item);
             }
        }
        else
        {
            var rowlast = GetMsgIndex(g_rowObjLastSave);
            if (rowlast!=id)
            {
                g_listMsgIndex += rowlast;
                g_listMsgIndex += ",";
            }            
            g_listMsgIndex += id;
            g_listMsgIndex += ",";
            SetSelStyle(rowObj);
        }
    }      
}

function ClearMultiSel()
{
    g_listMsgIndex = "";
}

function ResetMultiSel()
{
    if (g_listMsgIndex == "") 
        return;
    var d = new Array();   
    d = g_listMsgIndex.split(",");   
    for (var i = 0; i <d.length; i++)   
    {   
        m = d[i];    
        var item = document.getElementById("itemId_"+ m);
        ResetStyle(item);
    }

    g_listMsgIndex = "";
}

function ResetStyle(rowObj)
{
	if (rowObj==null) return;

	/*var bkIndex = rowObj.getAttribute("bkIndex");
	var bdclr = g_clrBorder1;
	if (bkIndex == 2) 
	{
		bdclr = g_clrBorder2;
	}*/
	
	rowObj.style.backgroundColor=null;
	
	rowObj.style.borderColor=null;
	
	//if (rowObj.cells.length >0){rowObj.cells[0].style.cssText="border:1px "+bdclr+" solid;";}
	if (rowObj.cells.length >0){rowObj.cells[0].style.cssText="border:1px solid transparent;";}
}

function SetSelStyle(rowObj)
{
    if (rowObj==null) return;
    
     rowObj.style.backgroundColor= g_clrBgSel ;

    /*if (g_dwIEVersion > 5)
    {
       if (rowObj.cells.length > 0)
       {
          rowObj.cells[0].style.cssText="border:1px "+g_clrBorderSel+" solid;";
       }
    }*/
	if (rowObj.cells.length > 0)
	{
		rowObj.cells[0].style.cssText="border:1px "+g_clrBorderSel+" solid;";
	}
};

function GetMultiSel()
{
      return g_listMsgIndex;
}

function OnClickItem(rowObj)
{
    g_rowObjLastSelByKeyDown = rowObj;
    var bMultiSel = false;
    if (external.EnableMultiSel() && (g_rowObjLastSave !=null) && ( external.GetKeyState(17) < 0 || external.GetKeyState(16)<0))
    {
         bMultiSel = true;
         
         if (external.GetKeyState(16)<0) ///shift
         {
	        ResetMultiSel();
            var row1 = GetMsgIndex(rowObj);
            var row2 = GetMsgIndex(g_rowObjLastSave);
            if (row1 < row2)
	        {
	            for(i=row1;i<=row2;i++)
	            {
	                var item = document.getElementById("itemId_"+i);
                    AddToMultiSel(item,false);
	            }
	        }
            else
            {
                for(i=row2;i<=row1;i++)
                {
                     var item = document.getElementById("itemId_"+i);
                     AddToMultiSel(item,false);
                }
            }
        }
        else
        {
            AddToMultiSel(rowObj,true);  //ctrl
        }
    }
    else
    {
        ResetMultiSel();
        ResetStyle(g_rowObjLastSave);
        SetSelStyle(rowObj);
    }   
    if (!bMultiSel )
    {
        g_rowObjLastSave = rowObj;
        if (g_notify)
        {
            external.SetCurSel(GetMsgIndex(g_rowObjLastSave));
        }       
    }
	else
	{
	    if (g_notify)
        {
            external.SetMultiCurSel(GetMsgIndex(rowObj));
        }  
	}
}

function GetCurSel()
{
  if (g_rowObjLastSave!=null )
  {
     return GetMsgIndex(g_rowObjLastSave);
  }
  else
  {
	 return -1;
  }
}

function DeleteCurRow()
{
   if (g_rowObjLastSave!=null )
  {
     ItemTable.deleteRow(g_rowObjLastSave.rowIndex);
     g_rowObjLastSave = null;
  }
}

function DeleteRow(msgid)
{
    var item=document.getElementById("itemId_"+msgid);
    if (item)
    {
        if (g_rowObjLastSave !=null && g_rowObjLastSave.rowIndex == item.rowIndex)
            g_rowObjLastSave = null;
        ItemTable.deleteRow(item.rowIndex);
    }
}

function SetCurSelIndex(msgid)
{
	var selObj = window.getSelection();
	if (selObj != null)
	{
		selObj.removeAllRanges();
	}
    var item=document.getElementById("itemId_"+msgid);
    if (item != null && msgid >= 0)
    {  
        OnClickItem(item);
    }
}

function SelectMsgFromMonthCal(msgid)
{
  g_notify = false;
  try
  {
    //SetCurSelIndex(msgid)
    var item=document.getElementById("itemId_"+msgid);
    var dateHeight = 26;    //显示消息记录上面的日期
    var top = item.offsetTop - dateHeight;
    if (top < 0)
    {
        top = 0;
    }
    if (top < document.body.scrollTop)
    { 
      document.body.scrollTop = top;
    }
    else if ((item.offsetTop + item.clientHeight) > (document.body.clientHeight+document.body.scrollTop))
    {
      document.body.scrollTop =( item.offsetTop + item.clientHeight - document.body.clientHeight);
    }
  }
  catch(e){}
  g_notify = true;
}

function SelectMsg(msgid,bsel)
{
  g_notify = false;
  try
  {
    var item=document.getElementById("itemId_"+msgid);
    if (bsel)
    {
       OnClickItem(item)
    }
 
    var top = item.offsetTop;
    if (msgid == 0)
    {   //选第0条要显示最顶
        top = 0;
    }

    if (top< document.body.scrollTop)
    { 
      document.body.scrollTop = top;
    }
    else if ((item.offsetTop + item.clientHeight) > (document.body.clientHeight+document.body.scrollTop))
    {
        if (GetMsgIndex(item) ==  (external.GetCount() - 1))
            document.body.scrollTop = document.body.scrollHeight - document.body.clientHeight;
        else
            document.body.scrollTop =( item.offsetTop + item.clientHeight - document.body.clientHeight);
    }
  }
  catch(e){}
  g_notify = true;
}

function ScrollToBottom()
{
	if (g_nRowObjCount > 0)
	{
		scrollTo(0,document.body.scrollHeight);
		//SelectMsg(g_nRowObjCount-1,false);
	}
}

function ScrollToPosition() 
{
    //document.body.style.overflow.x == 'hidden'
    if(true)
    {
        if(g_gotoBottom == true)
        {
            scrollTo(0,document.body.scrollHeight+20);
        }
    }
}

function ScrollToTop()
{
    scrollTo(0,0);
     //SelectMsg(0,false);
}

function LoadNothing()
{
    g_nRowObjCount = 0;
    var Curpage=document.getElementById("Curpage");
    ClearMultiSel();
    if (Curpage != null)
    {
        Curpage.innerHTML = external.loadstring("MSGMGR_NOMSG");
    }
}

function LoadSearchResult()
{
    var Curpage = document.getElementById("Curpage");
    var head = "<table id='ItemTable' width=100% cellspacing=0  style='word-wrap:break-word;word-break:break-all;'>";
    var foot = "</table>";
    var nitem = external.GetCount();
    var fontName = external.GetFontName();
    var fontHeight = external.GetFontHeight();
    var ShowmsgHtml = "";
    var dCount = 0;
    if (nitem == 0)
    {
        ClearMultiSel();
        Curpage.innerHTML = "";
        window.scrollTo(0,0);  
        return;
    }
    g_nRowObjCount = nitem;
    var v1 = external.loadstring("MSGMGR_VIEWSYS");
    var v2 = external.loadstring("MSGMGR_VIEWMSG");
    var lastpath = "";
    var i = 0;
    var bbackchange = true;
    for (i = 0; i < nitem; i++)
    {  
		var hasmsg = external.GetAt(i);

        if (hasmsg == true)
        {
            //var sender = msgobj.sender;
            //var msgtext = msgobj.html;
            //var date   = msgobj.date;
            //var time  = msgobj.time;
            //var path  = msgobj.path;
            //var candispose = msgobj.candispose;
            //var id = msgobj.id;
            //var type = msgobj.type;
            //var bshowreply = msgobj.bshowreply;
            //var nodeuin = msgobj.nodeuin;
            //var datetime = msgobj.datetime;
            //var b0x4cmsg = msgobj.b0x4cmsg;
            //var bself = msgobj.bself;
            //var v_reply = msgobj.replytext;
        
			var sender = external.GetAt(i,"sender");
			var msgtext = external.GetAt(i,"html");
			var date   = external.GetAt(i,"date");
			var time  = external.GetAt(i,"time");
			var path  = external.GetAt(i,"path");
			var candispose = external.GetAt(i,"candispose");
			var id = external.GetAt(i,"id");
			var type = external.GetAt(i,"type");
			var bshowreply = false;//external.GetAt(i,"bshowreply");
			var nodeuin = external.GetAt(i,"nodeuin");
			var datetime = external.GetAt(i,"datetime");
			var b0x4cmsg = external.GetAt(i,"b0x4cmsg");
			var bself = external.GetAt(i,"bself");			
			var v_reply = external.GetAt(i,"replytext");	
		
            var view = "";
            if (candispose)
            {
                view = "<a href='#' onclick='javascript:OnDisposeItem(itemId_"+i+","+ datetime +");return false;'>"+v1+"</a>";
            }
             else
            {
                view = "<a href='#' onclick='javascript:OnDbClickItem(itemId_"+i+");return false;'>"+v2+"</a>";
            }
            
            var reply = "<a href='#' onclick='javascript:OnClickReply(\""+type+"\",\""+nodeuin+"\","+datetime+");return false;'>"+v_reply+"</a>";

            var bdclr = g_clrBorder1;
            
            var bkIndex = 1;
            if (i%2 != 0) 
            {
                bkIndex = 2;
                bdclr = g_clrBorder2;
            }
            if (path != lastpath)
            {
                ShowmsgHtml +=  "<tr style=color:#898989><td>"+path+"</td></tr>";
                lastpath = path;
                dCount++;
            }
            if (b0x4cmsg)
                ShowmsgHtml += "<tr bkIndex="+bkIndex+" style=bgcolor="+bdclr+" id=itemId_"+i+" onclick='OnClickItem(this)' ondblclick ='OnDbClickItem(this)'  onMouseOver='OnMouseTrackIn(this)' onMouseDown='OnMouseDownItem(this)' onMouseOut='OnMouseTrackOut(this)' dCount="+dCount+"><td id='tn'><div style=color:#000000;padding-left:10px;float:left;font-weight:bold;font-size:"+fontHeight+"px;font-family:"+fontName+";>"+sender+"</div><div id='tv' valign='top' align='right'  style=float:right;color:#898989;visibility:hidden;padding-left:20px;padding-right:8px;>"+view+"</div>";
            else
            {
                if (bself)
                    ShowmsgHtml += "<tr bkIndex="+bkIndex+" style=bgcolor="+bdclr+" id=itemId_"+i+" onclick='OnClickItem(this)' ondblclick ='OnDbClickItem(this)'  onMouseOver='OnMouseTrackIn(this)' onMouseDown='OnMouseDownItem(this)' onMouseOut='OnMouseTrackOut(this)' dCount="+dCount+"><td id='tn'><div style=color:#42B475;padding-left:10px;float:left;font-size:"+fontHeight+"px;font-family:"+fontName+";>"+sender+"   "+date+" "+time+"</div><div id='tv' valign='top' align='right'  style=float:right;color:#898989;visibility:hidden;padding-left:20px;padding-right:8px;>"+view+"</div>";
                else
                    ShowmsgHtml += "<tr bkIndex="+bkIndex+" style=bgcolor="+bdclr+" id=itemId_"+i+" onclick='OnClickItem(this)' ondblclick ='OnDbClickItem(this)'  onMouseOver='OnMouseTrackIn(this)' onMouseDown='OnMouseDownItem(this)' onMouseOut='OnMouseTrackOut(this)' dCount="+dCount+"><td id='tn'><div style=color:#006EFE;padding-left:10px;float:left;font-size:"+fontHeight+"px;font-family:"+fontName+";>"+sender+"   "+date+" "+time+"</div><div id='tv' valign='top' align='right'  style=float:right;color:#898989;visibility:hidden;padding-left:20px;padding-right:8px;>"+view+"</div>";
            }
                
            if (bshowreply)
            {
                ShowmsgHtml += "<div id='tv_reply' valign='top' align='right'  style=float:right;color:#898989;visibility:hidden;>"+reply+"</div>";
            }
            if (b0x4cmsg)
                ShowmsgHtml += "<div style=float:top;margin-top:20px;padding-left:10px;>"+msgtext+"</div></td></tr>";
            else
                ShowmsgHtml += "<div style=float:top;margin-top:20px;padding-left:20px;>"+msgtext+"</div></td></tr>";
        }
        else
        {
            ShowmsgHtml += "<tr bkIndex="+bkIndex+" bgcolor="+bdclr+" id=itemId_"+i+" onclick='OnClickItem(this)' ondblclick ='OnDbClickItem(this)'  onMouseOver='OnMouseTrackIn(this)' onMouseDown='OnMouseDownItem(this)' onMouseOut='OnMouseTrackOut(this)' dCount="+dCount+"><td id='tn'></td></tr>";        
        }
    }

    ClearMultiSel();
    Curpage.innerHTML = head +ShowmsgHtml + foot;
    //window.scrollTo(0,0);  
    //window.setTimeout("window.scrollTo(0,0);",500);
}

function LoadAIOSearchResult()
{
    var Curpage = document.getElementById("Curpage");
    var head = "<table id='ItemTable' width=100% cellspacing=0  style='word-wrap:break-word;word-break:break-all;'>";
    var foot = "</table>";
    var nitem = external.GetCount();
    var fontName = external.GetFontName();
    var fontHeight = external.GetFontHeight();
    var ShowmsgHtml = "";
    var dCount = 0;
    if (nitem == 0)
    {
        ClearMultiSel();
        Curpage.innerHTML = "";
        window.scrollTo(0,0);  
        return;
    }
    g_nRowObjCount = nitem;
    var v1 = external.loadstring("MSGMGR_VIEWSYS");
    var v2 = external.loadstring("MSGMGR_VIEWMSG");
    var i = 0;
    var bbackchange = true;
    for (i = 0; i < nitem; i++)
    {  
        var hasmsg = external.GetAt(i);
        if (hasmsg == true)
        {
			var sender = external.GetAt(i,"sender");
			var msgtext = external.GetAt(i,"html");
			var date   = external.GetAt(i,"date");
			var time  = external.GetAt(i,"time");
			var path  = external.GetAt(i,"path");
			var candispose = external.GetAt(i,"candispose");
			var id = external.GetAt(i,"id");
			var type = external.GetAt(i,"type");
			var nodeuin = external.GetAt(i,"nodeuin");
			var datetime = external.GetAt(i,"datetime");
			var bself = external.GetAt(i,"bself");
			var bLongName = external.GetAt(i,"bLongName");
			var v_reply = external.GetAt(i,"replytext");
			
            //var sender = msgobj.sender;
            //var msgtext = msgobj.html;
            //var date   = msgobj.date;
            //var time  = msgobj.time;
            //var path  = msgobj.path;
            //var candispose = msgobj.candispose;
            //var id = msgobj.id;
            //var type = msgobj.type;
            //var nodeuin = msgobj.nodeuin;
            //var datetime = msgobj.datetime;
            //var bself = msgobj.bself;
            //var bLongName = msgobj.bLongName;
               
            //var v_reply = msgobj.replytext;
			
            var view = "";
            if (candispose)
            {
                view = "<a href='#' onclick='javascript:OnDisposeItem(itemId_"+i+","+ datetime +");return false;'>"+v1+"</a>";
            }
            else
            {
                view = "<a href='#' onclick='javascript:OnDbClickItem(itemId_"+i+");return false;'>"+v2+"</a>";
            }
            
            var reply = "<a href='#' onclick='javascript:OnClickReply(\""+type+"\",\""+nodeuin+"\","+datetime+");return false;'>"+v_reply+"</a>";

            var bdclr = g_clrBorder1;
            
            var bkIndex = 1;
            if (i%2 != 0) 
            {
                bkIndex = 2;
                bdclr = g_clrBorder2;
            }
         
            if (bself)
            {
                if (bLongName)
                    ShowmsgHtml += "<tr bkIndex="+bkIndex+" style=bgcolor="+bdclr+" id=itemId_"+i+" onclick='OnClickItem(this)' ondblclick ='OnDbClickItem(this)'  onMouseOver='OnMouseTrackIn(this)' onMouseDown='OnMouseDownItem(this)' onMouseOut='OnMouseTrackOut(this)' dCount="+dCount+"><td id='tn'><div style=color:#42B475;padding-left:10px;float:left;font-size:"+fontHeight+"px;font-family:"+fontName+";>"+sender+"   "+date+" "+time+"</div><div id='tv' valign='top' align='right'  style=float:right;color:#898989;visibility:hidden;padding-left:10px;>"+view+"</div>";
                else
                    ShowmsgHtml += "<tr bkIndex="+bkIndex+" style=bgcolor="+bdclr+" id=itemId_"+i+" onclick='OnClickItem(this)' ondblclick ='OnDbClickItem(this)'  onMouseOver='OnMouseTrackIn(this)' onMouseDown='OnMouseDownItem(this)' onMouseOut='OnMouseTrackOut(this)' dCount="+dCount+"><td id='tn'><div style=color:#42B475;padding-left:10px;float:left;font-size:"+fontHeight+"px;font-family:"+fontName+";>"+sender+"   "+date+" "+time+"</div><div id='tv' valign='top' align='right'  style=float:right;color:#898989;visibility:hidden;padding-left:10px;>"+view+"</div>";
            }
            else
            {
                if (bLongName)
                    ShowmsgHtml += "<tr bkIndex="+bkIndex+" style=bgcolor="+bdclr+" id=itemId_"+i+" onclick='OnClickItem(this)' ondblclick ='OnDbClickItem(this)'  onMouseOver='OnMouseTrackIn(this)' onMouseDown='OnMouseDownItem(this)' onMouseOut='OnMouseTrackOut(this)' dCount="+dCount+"><td id='tn'><div style=color:#006EFE;padding-left:10px;float:left;font-size:"+fontHeight+"px;font-family:"+fontName+";>"+sender+"   "+date+" "+time+"</div><div id='tv' valign='top' align='right'  style=float:right;color:#898989;visibility:hidden;padding-left:10px;>"+view+"</div>";
                else
                    ShowmsgHtml += "<tr bkIndex="+bkIndex+" style=bgcolor="+bdclr+" id=itemId_"+i+" onclick='OnClickItem(this)' ondblclick ='OnDbClickItem(this)'  onMouseOver='OnMouseTrackIn(this)' onMouseDown='OnMouseDownItem(this)' onMouseOut='OnMouseTrackOut(this)' dCount="+dCount+"><td id='tn'><div style=color:#006EFE;padding-left:10px;float:left;font-size:"+fontHeight+"px;font-family:"+fontName+";>"+sender+"   "+date+" "+time+"</div><div id='tv' valign='top' align='right'  style=float:right;color:#898989;visibility:hidden;padding-left:10px;>"+view+"</div>";
            }
            
            if (bLongName)
                ShowmsgHtml += "<div class=msgContentDiv>"+msgtext+"</div></td></tr>";
            else
                ShowmsgHtml += "<div class=msgContentDiv>"+msgtext+"</div></td></tr>";
        }
        else
        {
            ShowmsgHtml += "<tr bkIndex="+bkIndex+" bgcolor="+bdclr+" id=itemId_"+i+" onclick='OnClickItem(this)' ondblclick ='OnDbClickItem(this)'  onMouseOver='OnMouseTrackIn(this)' onMouseDown='OnMouseDownItem(this)' onMouseOut='OnMouseTrackOut(this)' dCount="+dCount+"><td id='tn'></td></tr>";        
        }
    }

    ClearMultiSel();
    Curpage.innerHTML = head +ShowmsgHtml + foot;
    
    //window.scrollTo(0,0);  
    //window.setTimeout("window.scrollTo(0,0);",500);
}

function CreateFrames()
{
    if (document.all.oleFrame!=null)
    {
        if (document.all.oleFrame.length!=null)
        {
             for (i=0;i<document.all.oleFrame.length;i++)
            {
				var npframe = document.all.oleFrame[i];
                external.OnCreateFrame(npframe.getAttribute("nodetype"),npframe.getAttribute("key"),parseInt(npframe.getAttribute("mid")),parseInt(npframe.getAttribute("im")),npframe.frame);
			}
        }
        else
        {
			var npframe = document.all.oleFrame;
            external.OnCreateFrame(npframe.getAttribute("nodetype"),npframe.getAttribute("key"),parseInt(npframe.getAttribute("mid")),parseInt(npframe.getAttribute("im")),npframe.frame);
		};
    }
}

function OnUserKeyDown()
{
    if (window.event.ctrlKey && (window.event.keyCode == 70)) // 屏蔽Ctrl+F
    {   
        window.event.keyCode = 0;
        window.event.returnValue = false;   
    }
    else if (window.event.keyCode == 8)
    {
        external.OnBackKeyDown();
       	window.event.keyCode = 0;
        window.event.returnValue = false;
    }
} 
 
function SetBodyFont()
{	
	var os = navigator.userAgent.toUpperCase();
	if (os.indexOf("NT 6.") > -1)
	{
		document.body.style.fontFamily="微软雅黑,Tahoma,Verdana,Arial,Helvetica,sans-serif;";
	}
}

function OnCreateCSS(filename)
{
    // filename si an external css file
	var style = document.createElement("link");
	style.rel = "stylesheet";
	style.type = "text/css";	
	style.href = filename;
	
	document.getElementsByTagName("head")[0].appendChild(style);
}

function ImageZoom(image)
{
	var parent = image.parentNode;
	if (parent) 
	{
		var span = parent.lastChild;
		if (span) span.style.display='block';
	}
}
</script>

</head>
<body  onkeydown="OnUserKeyDown()">
    <div class=pageDiv id="ThePage">
        <div class=pageDiv id="Curpage" />
    </div>

    <script language="javascript">
	    // g_dwIEVersion = external.GetIEVer();
	    OnThemeColorChange();
    </script>
    <script>
        document.onselectstart = function()
        {
            if (external.GetKeyState(17) < 0 || external.GetKeyState(16)<0)
            {
                event.returnValue=false;
            }
            else
            {
                event.returnValue=true;
            }
        }
        document.onkeydown = function()
        {
            if (window.event.keyCode == 38)///up
            {
                if (g_rowObjLastSelByKeyDown == null)
                {
                    g_rowObjLastSelByKeyDown = g_rowObjLastSave;
                }
                event.returnValue=false;
                var rowlast = GetMsgIndex(g_rowObjLastSelByKeyDown);
                if (rowlast > 0)
                {
                    rowlast --;
                    SelectMsg(rowlast,true);
                    g_rowObjLastSelByKeyDown = document.getElementById("itemId_"+rowlast);
                    external.SetCurSel(rowlast);
                }
                else
                {
                    event.returnValue=true;
                }
               
            }
            else if (window.event.keyCode == 40) //down
            {
                if (g_rowObjLastSelByKeyDown == null)
                {
                    g_rowObjLastSelByKeyDown = g_rowObjLastSave;
                }
                event.returnValue=false;
                var rowlast = GetMsgIndex(g_rowObjLastSelByKeyDown);
                g_nRowObjCount = external.GetCount();

                if (rowlast < g_nRowObjCount-1)
                {
                    rowlast ++;
                    SelectMsg(rowlast,true);
                    g_rowObjLastSelByKeyDown = document.getElementById("itemId_"+rowlast);
                    external.SetCurSel(rowlast);
                }
                else
                {
                    event.returnValue=true;
                }
    
            }
            else
            {
                event.returnValue=true;
            }
        }
    </script>

    <script>
        function OnMoveOle(obj)
        {
            external.OnMouseMoveOle(event.screenX,event.screenY,obj);
        }   
        function OnMoveDownOle(obj)
        {
            external.OnMouseDownOle(event.screenX,event.screenY,obj);
        }
        function OnMoveUpOle(obj)
        {
            external.OnMouseUpOle(event.screenX,event.screenY,obj);
        }
    </script>
</body>
</html>
